package com.happyfamily.springboot.crowdsourcingplatform.dao.pan;

import com.happyfamily.springboot.crowdsourcingplatform.base.result.Results;
import com.happyfamily.springboot.crowdsourcingplatform.model.Orders;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Administrator
 * @create 2020/02/28 11:25
 */
@Mapper
public interface OrderUserDao
{


	/**
	 * 添加购买作品的订单
	 * @param workid
	 * @param ouseraccount
	 * @return
	 */
	@Insert("insert into orders(workid, pid, tid,ostarttime, ouseraccount,successcase) values(#{workid},8,5,curdate(),#{ouseraccount},1)")
	int addOrderUser(@Param("workid") String workid, @Param("ouseraccount") String ouseraccount);


	/**
	 * 雇主个人订单
	 * @param offset
	 * @param limit
	 * @param ouseraccount
	 * @return
	 */
	@Select("select * from orders where ouseraccount=#{ouseraccount} order by ostarttime desc  limit #{offset},#{limit}")
	List<Orders> getUserOderList(@Param("offset")Integer offset, @Param("limit")Integer limit, @Param("ouseraccount")String ouseraccount);


	/**
	 * 查询个人购买订单的数据条数
	 * @return
	 */
	@Select("select count(*) from orders where ouseraccount=#{ouseraccount}")
	Long countUserOrder(String ouseraccount);

	/**
	 * 购买作品生成order_from
	 * @param oid
	 */
	@Insert("insert into order_form(orderid, generatetime, generatematter) values(#{oid},curdate(),'购买作品生成订单，订单为待付款')")
	void addOrderFrom(Integer oid);
}
